<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4428：[Nwerc2015]Debugging调试</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Nwerc2015]Debugging调试</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Nwerc2015]Debugging调试</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Nwerc2015]Debugging调试                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>Your fancy debugger will not help you in this matter. There are many ways in which code can produce different behavior between debug and release builds, and when this happens, one may have to resort to more primitive forms of debugging.</div>
<div>So you and your printf are now on your own in the search for a line of code that causes the release build to crash. Still you are lucky: adding printf statements to this program affects neither the bug (it still crashes at the same original code line) nor the execution time (at least not notably). So even the naive approach of putting a printf statement before each line, running the program until it crashes, and checking the last printed line, would work.</div>
<div></div>
<div>However, it takes some time to add each printf statement to the code, and the program may have a lot of lines. So perhaps a better plan would involve putting a printf statement in the middle of the program, letting it run, seeing whether it crashes before the added line, and then continuing the search in either the first or second half of the code.</div>
<div></div>
<div>But then again, running the program may take a lot of time, so the most time-efficient strategy might be something in between. Write a program that computes the minimum worst-case time to find the crashing line (no matter where it is), assuming you choose an optimal strategy for placing your printf statements.</div>
<div></div>
<div>We're releasing the new version in five hours, so this issue is escalated and needs to be fixed ASAP.</div>
<div></div>
<div>Input</div>
<div>The input consists of one line with three integers:</div>
<div></div>
<div>n ( 1&le;n&le;106 ), the number of code lines;</div>
<div>r ( 1&le;r&le;109 ), the amount of time it takes to compile and run the program until it crashes;</div>
<div>p ( 1&le;p&le;109 ), the time it takes to add a single printf line.</div>
<div>You have already run the program once and therefore already know that it does crash somewhere.</div>
<div></div>
<div>Output</div>
<div>Output the worst-case time to find the crashing line when using an optimal strategy.</div>
<div></div>
<div>你看中的调试器将不会在这件事上帮助你。有代码可以通过多种方式在调试与正式发布的间隙发生不同的行为，当出现这种情况，我们可能不得不求助于更原始的调试方式。</div>
<div>所以，你和你的printf现在在寻求一行导致该发布版本崩溃的代码。幸运的是：增加printf语句到程序里，既不会制造bug（仍然崩溃在同一原始的代码行），也没有影响执行时间（至少不显著）。 因此，即使在每行前加一个printf语句，运行程序，直到它崩溃，并检查最后打印行。</div>
<div>然而，它需要一些时间来添加每个printf语句到代码，并且该程序可以具有很多行。</div>
<div>因此，把一个printf语句在程序的中间或许是一个更好的计划，让它运行，观察它是否在加入行前崩溃，然后继续在代码的前一或后一半寻找。</div>
<div>不过话又说回来，运行程序可能需要很多时间，所以时效最优的策略可能是介于两者之间。</div>
<div>编写计算最坏情况下的最小时间来寻找崩溃行（无论它在哪里），认为你选择最优的加printf语句策略。</div>
<div>我们在5小时内发布新的版本，所以这个问题十分严重，需要尽快解决。</div>
<p></p></p><hr/><h3>输入格式</h3><p><div>输入包括一行三个整数：</div>
<div>n（1&le;n&le;10^6），代码行的数目;</div>
<div>r（1&le;r&le;10^9），编译和运行程序直到它崩溃的时间量;</div>
<div>p（1&le;p&le;10^9），增加单个的printf行所花费的时间。</div>
<div>您已经运行一次程序，因此已经知道它崩溃的地方。</div>
<p></p></p><hr/><h3>输出格式</h3><p><div>输出的最坏情况使用最优策略找到崩溃行的时间。</div>
<p></p></p><hr/><h3>样例输入</h3><pre>Sample Input 1	
1 100 20 
Sample Input 2	
10 10 1 
Sample Input 3	
16 1 10</pre><hr/><h3>样例输出</h3><pre>Sample Output 1
0
Sample Output 2
19
Sample Output 3
44
</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>没有写明来源</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4428" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4428" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>